package com.zd.manage.controller;

import java.util.Objects;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.zd.manage.entity.BaseBody;
import com.zd.manage.entity.Person;
import com.zd.manage.service.PersonService;
@Controller

public class LoginController extends BaseController {
	@Autowired
	PersonService personService;
	@RequestMapping(value="/login")
	public String login(){
//		return "login";
		return "login";
	};
	@RequestMapping("/index")
	public String index(Model m){
		BaseBody b = personService.findAllPerson();
		m.addAttribute("name", "ytt");
		m.addAttribute("persons", b);
		return "index";
	};
	
	@RequestMapping(value="/doLogin")
	public String doLogin(String username,String password){
		if(Objects.equals(username,"admin") && Objects.equals(password, "111111")){
			return "redirect:index";
		}else{
			return "redirect:login";
		}
	}
	
	
}
